#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>

int main(int argc,char* argv[])
{
    printf("获取当前进程ID:%u\n",getpid());
    int pid = fork();
    printf("被创建的进程ID：%u\n",pid);

    if (pid)
    {
        //说明是父进程
        while (1)
        {
            printf("我是父进程：%d %d\n",getpid(),getppid());
            sleep(1);
        }
    }else
    {
        //这里是子进程
        while (1)
        {
            printf("我是子进程：%d %d\n",getpid(),getppid());
            sleep(1);
        }
    }

    return 0;
}
